import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n



// import '@/styles/index.scss' // global css


import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control


// store.subscribe((mutation, state) => {
//   // require('@/styles/index.scss')
//   // 处理状态变化的回调函数
//   console.log(mutation, 'mutation');
//   console.log(state, 'state');
//   if (state.themes.themesVal === 0) {
//     console.log(0);
//     require('@/styles/index.scss')
//   } else if (state.themes.themesVal === 1) {
//     console.log(1);
//     require('@/styles/index2.scss')
//   } else if (state.themes.themesVal === 2) {
//     console.log(2);
//     require('@/styles/index3.scss')
//   } else if (state.themes.themesVal === 3) {
//     console.log(3);
//     require('@/styles/index4.scss')
//   }
// })


/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
Vue.use(ElementUI)

Vue.config.productionTip = false


new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App),
  computed: {
    vuexData: function () {
      return this.$store.state.themes.themesVal; // 将 Vuex 中的 themesVal 数据映射为计算属性 vuexData
    }
  },
  watch: {
    vuexData: function (newValue) {
      // 当 vuexData 发生变化时的回调函数
      // console.log('数据发生变化：', newValue);

      // 在这里更新引入的文件
      // updateFile(newValue);Vue.component('my-plugin', () => import('./MyPlugin.js'));
      // if (newValue === 0) {
      //   console.log(0);
      //   require('@/styles/index.scss')
      // } else if (newValue === 1) {
      //   console.log(1);
      //   require('@/styles/index2.scss')
      // } else if (newValue === 2) {
      //   console.log(2);
      //   require('@/styles/index3.scss')
      // } else if (newValue === 3) {
      //   console.log(3);
      //   require('@/styles/index4.scss')
      // }
      if (newValue === 0) {
        // console.log(0);
        require('@/styles/index.scss')

      } else if (newValue === 1) {
        // console.log(1);
        require('@/styles/index2.scss')
      } else if (newValue === 2) {
        // console.log(2);
        require('@/styles/index3.scss')
      } else if (newValue === 3) {
        // console.log(3);
        require('@/styles/index4.scss')
      }
    }
  }
})







